# 绝对引用，使我们的celery模块不会与原始的celery冲突
from __future__ import absolute_import, unicode_literals
# 导入原始的celery模块中的shared_task from xx import xx
from celery import shared_task
# 使用django内置函数发送邮件
from django.core.mail import send_mail
# 导入django的settings
from django.conf import settings


@shared_task
def send_email_task(username, token, email):
    subject = '美多商城会员注册'
    message = ''
    from_email = settings.EMAIL_FROM
    recipient_list = [email]
    html_message = '<h3>{}欢迎关注美多商城，请点击链接激活<a href="http://127.0.0.1:8000/app01/active/?token={}">' \
                   '点击这里进行激活</a ></h3>'.format(username, token)

    send_mail(subject, message, from_email, recipient_list, html_message=html_message)
